/*
 * OREKIT-X
 * Copyright 2002-2008 CS Communication & Systemes
 * 
 * Parts of this software package have been licensed to CS
 * Communication & Systemes (CS) under one or more contributor license
 * agreements.  See the NOTICE file distributed with this work for
 * additional information.
 *  
 * This is an experimental copy of OREKIT from www.orekit.org.
 * Please use the original OREKIT from orekit.org for normal work
 * unrelated to this research project.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License.  You
 * may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.  See the License for the specific language governing
 * permissions and limitations under the License.
 */
package ore.attitudes;

import ore.Attitude;
import ore.Frame;
import ore.PositionVelocity;
import ore.Transform;
import ore.errors.OrekitException;
import ore.frames.FramesFactory;
import ore.time.AbsoluteDate;

import org.apache.commons.math.geometry.Rotation;

/**
 * This class handles an inertial attitude law.
 * 
 * Instances of this class are immutable.
 * 
 * @author Luc Maisonobe
 */
public class InertialLaw
    extends Object
    implements ore.AttitudeLaw
{
    /**
     * Attitude law aligned with the EME2000 frame.
     */
    public static final InertialLaw EME2000_ALIGNED =
        new InertialLaw(Rotation.IDENTITY);



    public final Frame satelliteFrame;

    /** 
     * @param rotation rotation from EME2000 to the desired satellite
     * frame
     */
    public InertialLaw(Rotation rotation) {
        super();
        this.satelliteFrame = new Frame(FramesFactory.getEME2000(), new Transform(rotation), null);
    }


    /** {@inheritDoc} */
    public Attitude getState(AbsoluteDate date, PositionVelocity pv, Frame frame)
        throws OrekitException
    {
        Transform t = frame.getTransformTo(satelliteFrame, date);
        return new Attitude(frame, t.getRotation(), t.getRotationRate());
    }

}
